<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <meta name="viewport"
        content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0" />
    <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
    <link rel="stylesheet" type="text/css" href="../css/aui.2.0.css" />
</head>

<body>
    <header class="aui-bar aui-bar-nav main-header">
        <a class="aui-pull-left aui-btn" tapmode onclick="closeWin();">
            <span class="aui-iconfont aui-icon-left"></span>
        </a>
        <div class="aui-title" id="title">
            滑橇替换
        </div>
    </header>
    <div class="aui-bar aui-bar-nav sub-header"></div>
    <div class="aui-content aui-margin-b-15" style="margin-top:50px;padding-bottom: 50px;">
        <div class="white_background">
            <ul class="aui-list aui-form-list">

                <li class="aui-list-item">
                    <div class="aui-list-item-inner">
                        <div class="aui-list-item-label">滑橇号</div>
                        <input type="text" class="aui-input" placeholder="请输入滑橇号" style="width: 80%;font-size: 16px;"
                            id="skiddingCode" />
                    </div>
                </li>
                <li class="aui-list-item">
                    <div class="aui-list-item-inner">
                        <div class="aui-list-item-label">顺序号</div>
                        <input type="text" class="aui-input" placeholder="请输入顺序号" style="width: 80%;font-size: 16px;"
                            id="seq" />
                    </div>
                </li>

                <div class="aui-btn aui-btn-info aui-btn-block" onclick="search()">查询</div>
            </ul>
        </div>
        <ul class="ui-selectee" id="tbodyHtml">

        </ul>


    </div>


</body>
<script type="text/javascript" src="../script/api.js"></script>
<script type="text/javascript" src="../script/doT.min.js"></script>
<script type="text/javascript" src="../script/public.js"></script>
<script type="text/javascript" src="../script/jquery-1.8.2.min.js"></script>
<script type="text/javascript">
    //光标所在id
    //光标所在id
    var idSelector = "";




    var arrSave = [];
    var num = 0;
    var mrlnum = 0;
    //初始化查询仓库下拉框
    apiready = function () {
        search()
    }
    function search() {
        var arrSave = [];
        var skiddingCode = $("#skiddingCode").val()
        var seq = $("#seq").val()
        var un = localStorage.getItem('un');
        var serverUrl = localStorage.getItem('serverUrl');

        var url = serverUrl + "/app/getSkiddingOnlinePlan";
        var data = {
            values: { ////以表单方式提交参数（JSON对象）
                skiddingCode: skiddingCode,
                state: "0",
                seq: seq,
                un: un
            }
        };
        api.ajax({
            url: url,
            method: 'post',
            dataType: 'json',
            timeout: 300,
            returnAll: false,
            data: data
        }, function (ret, err) {
            if (ret) {
                var data = JSON.stringify(ret);
                var myobj = eval("(" + data + ")");
                if (myobj.code == '0') {
                    var list = eval(myobj.list);
                    var html = "";
                    for (var i = 0; i < list.length; i++) {
                        var model = {
                            seq: list[i].seq, //顺序号/当前顺序
                            skiddingCode: list[i].skiddingCode, //滑橇号
                            primerColor: list[i].primerColor,
                            paintColor: list[i].paintColor,
                            varnishColor: list[i].varnishColor,
                        }
                        arrSave.push(model)
                    }
                    setTable(arrSave);
                } else {
                    api.toast({
                        msg: myobj.message,
                        duration: 3000
                    });
                }
            }
        });
    }

    function setTable(list) {
        var html = "";
        // console.log(JSON.stringify(list))
        for (var i = 0; i < list.length; i++) {
            html += "<li class='sortable ui-selectee ui-sortable'>";
            html += "<div class='white_background'>"
            html += "<ul class='aui-list aui-media-list ui-selectee'>";

            html += "<li class='aui-list-item  ui-selectee' style='color: black !important'>";
            html += "<div class='aui-media-list-item-inner ui-selectee' >";
            html += "<div class='aui-list-item-inner ui-selectee'>";

            html += "<div class='aui-list-item-text ui-selectee' style='height: 25px;font-size:16px;font-weight:bold;' >";
            html += "<div class='aui-list-item-label ui-selectee list-tr-title'>当前顺序：</div>";
            html += "<div class='aui-list-item-inner ui-selectee'>" + list[i].seq + "</div>";
            html += "</div>";

            html += "<div class='aui-list-item-text ui-selectee' style='height: 25px;'>";
            html += "<div class='aui-list-item-label ui-selectee list-tr-title'>滑橇号</div>";
            html += "<div class='aui-list-item-inner ui-selectee'>" + list[i].skiddingCode + "</div>";
            html += "</div>";
            html += "<div class='aui-list-item-text ui-selectee' style='height: 25px;'>";
            html += "<div class='aui-list-item-label ui-selectee list-tr-title'>底漆颜色</div>";
            html += "<div class='aui-list-item-inner ui-selectee'>" + list[i].primerColor + "</div>";
            html += "</div>";
            html += "<div class='aui-list-item-text ui-selectee' style='height: 25px;'>";
            html += "<div class='aui-list-item-label ui-selectee list-tr-title'>色漆颜色</div>";
            html += "<div class='aui-list-item-inner ui-selectee'>" + list[i].paintColor + "</div>";
            html += "</div>";
            html += "<div class='aui-list-item-text ui-selectee' style='height: 25px;'>";
            html += "<div class='aui-list-item-label ui-selectee list-tr-title' style='width:52%'>清漆颜色</div>";
            html += "<div class='aui-list-item-inner ui-selectee'>" + list[i].varnishColor + "</div>";
            html += "<div class='aui-list-item-right aui-btn ui-selectee' style='margin-bottom:10px; background:red;color:#f5f5f5;' onclick='replaceSkidding(\"" + list[i].seq + "\");'>滑橇替换</div>";

            html += "</div>";

            html += "</div>";
            html += "</div>";
            html += "</li>";
            html += "</ul>";
            html += "</div>";
            html += "</li>";
        }
        $api.html($api.byId("tbodyHtml"), html);
    };

    function replaceSkidding(seq) {
        var dialogBox = api.require('dialogBox');
        dialogBox.input({
            keyboardType: 'default',
            texts: {
                title: '滑橇替换',
                placeholder: '请输入滑橇号',
                leftBtnTitle: '取消',
                rightBtnTitle: '确定'
            },
            styles: {
                bg: '#fff',
                corner: 2,
                w: 300,
                h: 240,
                title: {
                    h: 60,
                    alignment: 'center',
                    size: 14,
                    color: '#000',
                    marginT: 30,
                },
                input: {
                    h: 60,
                    y: 30,
                    marginT: 15,
                    marginLeft: 10,
                    marginRight: 10,
                    textSize: 20,
                    textColor: '#000',
                    corner: 5,                  //（可选项）数字类型；对输入框圆角大小；默认：0

                },
                dividingLine: {
                    width: 0.5,
                    color: '#696969'
                },
                left: {
                    bg: 'rgba(0,0,0,0)',
                    color: '#007FFF',
                    size: 12,
                    h: 40,                //(可选项) 数字类型；右边按钮的高度；默认：40
                    w: 60,                   //(可选项) 数字类型；左边按钮的宽度；默认：提示框的宽度的一半
                    marginB: 10,            //(可选项) 数字类型；左边按离底部的边距；默认：0
                    corner: 5,              //(可选项) 数字类型；左边按钮的圆角；默认：0
                    widhtBorder: 1,         //(可选项) 数字类型；左边按钮的边宽；默认：0
                    normalBorderColor: '#778899', //(可选项) 数字类型；左边按钮的边宽颜色；默认：'rgba(0,0,0,0)'
                    activeBorderColor: '#0000CD', //(可选项) 数字类型；左边按钮的高亮状态下边宽颜色；默认：'rgba(0,0,0,0)'
                    activeColor: '#006400', //(可选项) 数字类型；左边按钮的高亮状态下标题颜色；默认：'rgba(0,0,0,0)'
                    activeBg: '#6B8E23'   //(可选项) 数字类型；左边按钮的高亮状态下背景颜色；默认：'rgba(0,0,0,0)'
                },
                right: {
                    bg: 'rgba(0,0,0,0)',
                    color: '#007FFF',
                    size: 12,
                    h: 40,                //(可选项) 数字类型；右边按钮的高度；默认：40
                    w: 60,                   //(可选项) 数字类型；右边按钮的宽度；默认：提示框的宽度的一半
                    marginB: 10,            //(可选项) 数字类型；右边按离底部的边距；默认：0
                    corner: 5,              //(可选项) 数字类型；右边按钮的圆角；默认：0
                    widhtBorder: 1,         //(可选项) 数字类型；右边按钮的边宽；默认：0
                    normalBorderColor: '#778899', //(可选项) 数字类型；右边按钮的边宽颜色；默认：'rgba(0,0,0,0)'
                    activeBorderColor: '#0000CD', //(可选项) 数字类型；右边按钮的高亮状态下边宽颜色；默认：'rgba(0,0,0,0)'
                    activeColor: '#006400', //(可选项) 数字类型；右边按钮的高亮状态下标题颜色；默认：'rgba(0,0,0,0)'
                    activeBg: '#6B8E23'   //(可选项) 数字类型；右边按钮的高亮状态下背景颜色；默认：'rgba(0,0,0,0)'
                }
            }
        }, function (ret) {
            //新滑橇号
            var skiddingCodeNew = ret.text;

            //取消
            if (ret.eventType == 'left') {
                dialogBox.close({
                    dialogName: 'input'
                });

                //确定
            } else {

                if (skiddingCodeNew == null || skiddingCodeNew == "" || skiddingCodeNew == undefined) {
                    api.toast({
                        msg: "请输入滑橇号!",
                        duration: 3000
                    });
                } else {
                    dialogBox.close({
                        dialogName: 'input'
                    });

                    save(seq, skiddingCodeNew);
                }
            }
        });
    }
    function save(seq, skiddingCodeNew) {

        var un = localStorage.getItem('un');
        var serverUrl = localStorage.getItem('serverUrl');
        var url = serverUrl + "/app/saveSkiddingReplace";
        var data = {
            values: { ////以表单方式提交参数（JSON对象）
                seq: seq,
                skiddingCodeNew: skiddingCodeNew,
                un: un
            }
        };
        api.ajax({
            url: url,
            method: 'post',
            dataType: 'json',
            timeout: 300,
            returnAll: false,
            data: data
        }, function (ret, err) {
            if (ret) {
                var data = JSON.stringify(ret);
                var myobj = eval("(" + data + ")");
                if (myobj.code == '0') {
                    api.toast({
                        msg: "替换成功",
                        duration: 3000
                    });
                    search()
                } else {
                    api.toast({
                        msg: myobj.message,
                        duration: 3000
                    });
                }
            }
        });
    }

    //返回按钮
    function closeWin() {
        api.closeWin({});
    }
</script>

</html>